import java.util.Scanner;

public class Main {
    public static Boolean isMatch(){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        SeqStack<String> st = new SeqStack<>();
        String[] chars = s.split("");

        for (int i = 0; i < chars.length; i++) {
            if(chars[i].equals("[")||chars[i].equals("(")||chars[i].equals("{")){
                st.push(chars[i]);
            }else {
                if(st.empty()) {
                    return false;
                }
                if((chars[i].equals("]")&&st.top().equals("["))
                        ||(chars[i].equals(")")&&st.top().equals("("))
                        ||(chars[i].equals("}")&&st.top().equals("{"))) {
                    st.pop();
                }else{
                    return false;
                }
            }
        }
        if(st.empty())
            return true;
        return false;
    }

    public static Boolean isPal(){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        LinkStack<String> st = new LinkStack<String>();
        String[] chars = s.split("");
        for (int i = 0; i < chars.length/2; i++){
            st.push(chars[i]);
        }
        int i =chars.length/2;
        if(chars.length%2!=0)
            i++;
        for(;i<chars.length;i++){
            if(st.top().equals(chars[i]))
                st.pop();
            else
                return false;
        }
        if(st.empty())
            return true;
        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("--------括号匹配--------(3示例)");
        int n = 3;
        while(n!=0){
            if (isMatch()) {
                System.out.println("Match");
            } else {
                System.out.println("NoMatch");
            }
            n--;
        }

        System.out.println("--------回文串--------(2示例)");
        n = 2;
        while(n!=0){
            if (isPal()) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            n--;
        }
    }
}